package com.zmzncs.lmtc.module.customer.controller;


import com.zmzncs.lmtc.common.pojo.Rest;
import com.zmzncs.lmtc.common.util.JsonUtil;
import com.zmzncs.lmtc.common.util.RestUtil;
import com.zmzncs.lmtc.module.customer.pojo.month_record.MonthRecordDTO;
import com.zmzncs.lmtc.module.customer.pojo.month_record.MonthRecordTableVO;
import com.zmzncs.lmtc.module.customer.service.MonthRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 月租车信息表 前端控制器
 * </p>
 *
 * @author 作者/order/orderInfo/getParkingOwnerData
 */
@Api(tags = "月租")
@RestController
@RequestMapping("/customer/month-record")
public class MonthRecordController {

    @Autowired
    MonthRecordService monthRecordService;

    @ApiOperation(value = "昨天、今天、本周、本月、本年的车场主月租缴费")
    @ApiImplicitParams({
            @ApiImplicitParam(name="parkId", value="停车场id"),
            @ApiImplicitParam(name="dateType", value="时间类型（1：昨天、2：今天、3：本周、4：本月，5：本年）"),
    })
    @GetMapping("get-month-reserve-amount-by-date")
    public Rest<String> getMonthRecordAmountByDate(@RequestParam Long parkId, @RequestParam Integer dateType) {
        String paidAmountByDate = monthRecordService.getMonthRecordAmountByDate(parkId, dateType);

        return RestUtil.success(paidAmountByDate);
    }

    @ApiOperation(value = "查询月租列表信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "parkId", value = "停车场id"),
            @ApiImplicitParam(name = "monthStatus", value = "月租状态（1：全部、2：临近到期、3：到期未续）"),
    })
    @GetMapping("get-month-reserve-by-status")
    public Rest<List<MonthRecordTableVO>> getMonthRecordByStatus(@RequestParam Long parkId, @RequestParam Integer monthStatus) {
        List<MonthRecordDTO> monthRecordDTOList = monthRecordService.getMonthRecordByStatus(parkId, monthStatus);
        List<MonthRecordTableVO> tableVOS = JsonUtil.listTransform(monthRecordDTOList, MonthRecordTableVO.class);

        return RestUtil.success(tableVOS);
    }
}

